package com.yanqu.road.entity.activity.silkroad.config;

import com.yanqu.road.entity.FieldTypeAnnotation;
import com.yanqu.road.utils.property.Property;
import com.yanqu.road.utils.property.PropertyHelper;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@FieldTypeAnnotation(tableName = "t_s_activity_silkroad_event")
public class SilkRoadEventConfig {
    @FieldTypeAnnotation(select = true, orderASC = true, isIndex = true)
    private int activityId;
    @FieldTypeAnnotation(desc = "地点id", isIndex = true)
    private int id;
    @FieldTypeAnnotation(desc = "事件类型")
    private int eventType;
    @FieldTypeAnnotation(desc = "事件描述")
    private String eventDesc;
    @FieldTypeAnnotation(desc = "图标")
    private String icon;
    @FieldTypeAnnotation(desc = "奖励")
    private String rewards;
    private Map<Integer, List<List<Property>>> rewardsListMap = new HashMap<>();
    @FieldTypeAnnotation(desc = "特殊奖励")
    private String specialRewards;
    private Map<Integer, List<List<Property>>> specialRewardsListMap = new HashMap<>();

    public int getActivityId() {
        return activityId;
    }

    public void setActivityId(int activityId) {
        this.activityId = activityId;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getEventType() {
        return eventType;
    }

    public void setEventType(int eventType) {
        this.eventType = eventType;
    }

    public String getEventDesc() {
        return eventDesc;
    }

    public void setEventDesc(String eventDesc) {
        this.eventDesc = eventDesc;
    }

    public String getIcon() {
        return icon;
    }

    public void setIcon(String icon) {
        this.icon = icon;
    }

    public String getRewards() {
        return rewards;
    }

    public void setRewards(String rewards) {
        this.rewards = rewards;
        String[] split = rewards.split("&");
        for (int i = 0; i < split.length; i++) {
            this.rewardsListMap.put(i+1, PropertyHelper.parseNewStringToPropertyList(split[i]));
        }
    }

    public String getSpecialRewards() {
        return specialRewards;
    }

    public void setSpecialRewards(String specialRewards) {
        this.specialRewards = specialRewards;
        String[] split = specialRewards.split("&");
        for (int i = 0; i < split.length; i++) {
            this.specialRewardsListMap.put(i+1, PropertyHelper.parseNewStringToPropertyList(split[i]));
        }
    }

    public List<List<Property>> getRewardsRandomList(int chose) {
        return new ArrayList<>(rewardsListMap.getOrDefault(chose, new ArrayList<>()));
    }

    public List<List<Property>> getSpecialRewardsRandomList(int chose) {
        return new ArrayList<>(specialRewardsListMap.getOrDefault(chose, new ArrayList<>()));
    }
}
